#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n < 3)
	{
		cout << -1 << endl;
		return 0;
	}
	if ((n - 1) % 2 == 0)
	{
		cout << 2 << endl; return 0;
	}
	if ((n - 1) % 2 == 1 && n % 4 == 0)
	{
		cout << 3 << endl;
		return 0;
	}
	if ((n - 1) % 2 == 1)
	{
		cout << 4 << endl;
		return 0;
	}
	return 0;
}
